package mailcommon.entities;

import java.io.Serializable;
import java.util.Date;
import mailcommon.helpers.DateHelper;

public class Letter implements Serializable {

    private String sender;
    private String recipient;
    private Date date;
    private String subject;
    private String body;
    private int id;
    private boolean old;

    public Letter() {
    }

    public Letter(String senderAddress, String recipientAddress,
            Date date, String subject, String body) {
        this.body = body;
        this.date = date;
        this.recipient = recipientAddress;
        this.sender = senderAddress;
        this.subject = subject;
        old = false;
    }

    public Letter(String senderAddress, String recipientAddress,
            String date, String subject, String body) {
        this(senderAddress, recipientAddress,
                DateHelper.getInstance().parse(date),
                subject, body);
    }

    public Letter(String senderAddress, String recipientAddress,
            Date date, String subject, String body,
            boolean old, int id) {
        this.body = body;
        this.date = date;
        this.recipient = recipientAddress;
        this.sender = senderAddress;
        this.subject = subject;
        this.old = old;
        this.id = id;
    }

    public Letter(String senderAddress, String recipientAddress,
            String date, String subject, String body,
            boolean old, int id) {
        this(senderAddress, recipientAddress,
                DateHelper.getInstance().parse(date),
                subject, body, old, id);
    }

    public String getSenderAddress() {
        return sender;
    }

    public String getRecipientAddress() {
        return recipient;
    }

    public Date getDate() {
        return date;
    }

    public String getDateString() {
        return DateHelper.getInstance().format(date);
    }

    public String getSubject() {
        return subject;
    }

    public String getBody() {
        return body;
    }

    public int getId() {
        return id;
    }

    public boolean isRead() {
        return old;
    }

    public void read() {
        old = true;
    }
}
